package com.nikkerball.apps.darkhorse.model.evaluation.topic;

import com.nikkerball.apps.darkhorse.model.core.Learner;
import com.nikkerball.apps.darkhorse.model.core.Topic;
import com.nikkerball.apps.darkhorse.model.evaluation.EvaluationPeriod;
import com.nikkerball.apps.darkhorse.model.evaluation.base.Evaluation;
import org.hibernate.annotations.Cascade;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.List;

import static org.hibernate.annotations.CascadeType.*;

/**
 * Represents an TopicEvaluation
 *
 * @author marius (created on 2010-12-05)
 */
@Entity
@Table(name = "TopicEvaluation")
public class TopicEvaluation extends Evaluation {

    // ----- instance fields -----

    private Topic topic;

    private List<TopicObservation> topicObservations;

    private List<TopicReview> topicReviews;

    // ----- constructors -----

    public TopicEvaluation() {
        super();
    }

    public TopicEvaluation(EvaluationPeriod evaluationPeriod, Learner learner) {
        super(evaluationPeriod, learner);
    }

    // ----- public methods -----

    @ManyToOne
    @JoinColumn(name = "topic_Id", nullable = false)
    public Topic getTopic() {
        return this.topic;
    }

    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    @OneToMany(mappedBy = "topicEvaluation")
    @Cascade({MERGE, PERSIST, SAVE_UPDATE, DETACH, DELETE})
    public List<TopicObservation> getTopicObservations() {
        return this.topicObservations;
    }

    public void setTopicObservations(List<TopicObservation> topicObservations) {
        this.topicObservations = topicObservations;
    }

    @OneToMany(mappedBy = "topicEvaluation")
    @Cascade({MERGE, PERSIST, SAVE_UPDATE, DETACH, DELETE})
    public List<TopicReview> getTopicReviews() {
        return this.topicReviews;
    }

    public void setTopicReviews(List<TopicReview> topicReviews) {
        this.topicReviews = topicReviews;
    }
}
